home *** CD-ROM | disk | FTP | other *** search
/ Creative Computers / Creative Computers CD-ROM, Volume 1 (Legendary Design Technologies, Inc.)(1994).iso / shareware / fractals / sman / lib / mandlb.asm < prev    next >
Assembly Source File  |  1994-11-17  |  3KB  |  127 lines

  1. * SManCP
  2. * By David M. McKinstry.
  3. * This version completed 6/13/89
  4. * This is copyrighted by the author and not to be used in any commerical
  5. * application (excepting Amiga demonstrations) with out his permission.
  6. * However, it may be freely used any duplicated for any non-commercial
  7. * applications.
  8.  
  9.     INCLUDE    "exec/types.i"    ;Needed for SOFFSET macro
  10.     INCLUDE    "graphics/rastport.i"
  11.     INCLUDE    "intuition/intuition.i"
  12.  
  13.     XDEF    _PlotIt
  14.     XREF    _GfxBase
  15.  
  16.     XREF    _LVOSetAPen
  17.     XREF    _LVOWritePixel
  18.  
  19.  
  20.     XREF    _xtemp
  21.     XREF    _ytemp
  22.     XREF    _IntWindow
  23.     XREF    _CWRast
  24.     XREF    _SWidth
  25.     XREF    _SHeight
  26.     XREF    _S1Width
  27.     XREF    _S1Height
  28.     XREF    _Limit
  29.     XREF    _CurCnt
  30.     XREF    _MaxCnt
  31.     
  32.  
  33. _PlotIt:
  34.     move.l    _CurCnt,d0        ;Get Mandelbrot count
  35.     cmp.l    #$FFFF,d0    ;See if indicated as M.B. It won't be this big
  36.     bne.s    MandOut
  37.     move.l    #15,d0
  38.     bra.s    SetC
  39. MandOut:
  40.     ext.l    d0
  41.     lsr.l    #2,d0
  42.     add.l    #1,d0
  43. SetC:
  44.     move.l    _CWRast,a1
  45.     move.b    d0,rp_FgPen(a1)
  46.     move.l    _ytemp,d1
  47.     cmp.l    #49,d1
  48.     bge.s    OKay
  49.     movem.l    d0-d7/a0-a6,-(a7)
  50.     move.l    a1,-(a7)        ;Save raster port
  51.     move.l    _GfxBase,a6
  52.     jsr    _LVOSetAPen(a6)
  53.     move.l    _IntWindow,a0
  54.     move.w    wd_MouseY(a0),d0
  55.     cmp.w    #49,d0
  56.     blt.s    IntSet            ;Mouse in menu region
  57.     cmp.l    #10,_ytemp        ;See if y less than 12
  58.     ble.s    IntSet
  59.     bra.s    MySet
  60. IntSet:    move.l    _xtemp,d0
  61.     move.l    _ytemp,d1
  62.     move.l    (a7)+,a1
  63.     jsr    _LVOWritePixel(a6)
  64.     movem.l    (a7)+,d0-d7/a0-a6
  65.     rts
  66. MySet:    move.l    (a7)+,a1    ;Recover Raster port
  67.     movem.l    (a7)+,d0-d7/a0-a6
  68. OKay:    move.l    _xtemp,d0
  69.     bsr    SetOne
  70.     rts
  71.  
  72. SetOne:
  73.     cmp.w    _SWidth,d0
  74.     bge.s    SetNot
  75.     cmp.w    _SHeight,d1
  76.     bgt.s    SetNot
  77.     tst.l    d1        ;See if -
  78.     bmi.s    SetNot
  79.     bsr    SetPix
  80. SetNot:
  81.     rts
  82.  
  83. *SetPix has inputs of d0.w for x, d1.w for y, and a3 for the video pointer
  84. * Registers affected include d1, d2, and a0. It returns with the address
  85. * of the pixel in a0 and the bit to be set or cleared in d1
  86. SetPix:
  87.     movem.l    d0-d3/a0-a2,-(a7)
  88.     move.b    rp_FgPen(a1),d3        ;Get mask for rastport
  89.     move.l    rp_BitMap(a1),a1    ;Get pointer to bitmap
  90.     move.l    a1,a2        ;Save bit map pointer in a2
  91.     addq.l    #bm_Planes,a1    ;Get pointer to planes
  92.     move.w    d1,d2        ;See if y is - and get into d2
  93.     bmi.s    SetNo        ;Don't set if negative
  94.     cmp.w    (_S1Height+2),d1
  95.     bgt.s    SetNo
  96.     move.w    d1,d2        ;y is in d2
  97.     move.w    d0,d1        ;See if x is negative
  98.     bmi.s    SetNo        ;Don't set if is
  99.     cmp.w    (_S1Width+2),d0
  100.     bgt.s    SetNo        ;bcc.s    SetNo        ;If no carry then too big
  101.     move.l    d2,d1        ;Save y  in d1
  102.     mulu    _SWidth,d1    ;Get Screen width times y
  103.     add.l    d0,d1        ;Add in x coordinate
  104.     lsr.l    #3,d1        ;d1 is x/8
  105.     move.l    d1,d2
  106.     move.w    d0,d1        ;d1 is x
  107.     eori.w    #7,d1        ;Toggle lowest 3 bits.
  108.     andi.w    #7,d1        ;Get 7 - x(mod 8)
  109.     ext.l    d3
  110.     move.l    d3,d0        ;Move pen color into d0
  111.     move.b    bm_Depth(a2),d3    ;Get depth in d3
  112. SetPln:    move.l    (a1)+,a0    ;Get pointer to bit plane
  113.     adda.l    d2,a0        ;Add in offset    
  114.     btst    #0,d0        ;See if 1st color
  115.     beq.s    NoOne
  116.     bset    d1,(a0)        ;Set bit 7-x(mod8)
  117.     bra.s    PlnOne
  118. NoOne:    bclr    d1,(a0)
  119. PlnOne:    asr.l    #1,d0        ;Move next bit in color down.
  120.     sub.b    #1,d3        ;See if all planes done.
  121.     bne.s    SetPln
  122. SetNo:    movem.l    (a7)+,d0-d3/a0-a2
  123.     rts
  124.  
  125.  
  126.     END
  127.